/*
 * Copyright (C) 2008+ Spark Zheng
 *
 * src/test/test_str.c
 *
 */

#include <stdio.h>
#include <stdlib.h>

#include "str.h"

#define BUFF_SIZE 32

int main(int argc, char **argv)
{
	int ret = 0;
	char line[BUFF_SIZE] = "Copyright (C) 2008+ Spark Zheng";
	char orig[BUFF_SIZE] = " ";
	char replace[BUFF_SIZE] = "#";

	fprintf(stdout, "o_line is %s\n", line);
	ret += str_replace(line, BUFF_SIZE, orig, replace);
	fprintf(stdout, "r_line is %s[%d]\n", line, ret);

	in_addr_t ip = 0;
	char ip_str[INET_ADDRSTRLEN] = {0};
	if (argc >= 3) { 
		ip = atoi(argv[1]);
		ipv4_to_str(ip, ip_str);
		fprintf(stdout, "ip: %d, ip_str: %s.\n", ip, ip_str);
	} else {
		ip = str_to_ipv4(argv[1]);
		fprintf(stdout, "ip_str: %s, ip: %d.\n", argv[1], ip);
	}
	

	return 0;
}
